package com.shuhua.taskServer.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.LocalDateTime;
<<<<<<< HEAD
import java.util.Date;
=======
>>>>>>> 312a8547971bd28c72072d07caef702821bd7891

/**
 * MyBatis-Plus配置类
 */
@Configuration
public class MybatisPlusConfig {

    /**
     * 自动填充处理器
     */
    @Bean
    public MetaObjectHandler metaObjectHandler() {
        return new MetaObjectHandler() {
            @Override
            public void insertFill(MetaObject metaObject) {
<<<<<<< HEAD
                // 处理LocalDateTime类型字段
                this.strictInsertFill(metaObject, "createdAt", LocalDateTime::now, LocalDateTime.class);
                this.strictInsertFill(metaObject, "updatedAt", LocalDateTime::now, LocalDateTime.class);
                
                // 处理Date类型字段
                this.strictInsertFill(metaObject, "createdAt", Date::new, Date.class);
                this.strictInsertFill(metaObject, "updatedAt", Date::new, Date.class);
                this.strictInsertFill(metaObject, "collectTime", Date::new, Date.class);
                this.strictInsertFill(metaObject, "finishTime", Date::new, Date.class);
=======
                this.strictInsertFill(metaObject, "createdAt", LocalDateTime::now, LocalDateTime.class);
                this.strictInsertFill(metaObject, "updatedAt", LocalDateTime::now, LocalDateTime.class);
>>>>>>> 312a8547971bd28c72072d07caef702821bd7891
            }

            @Override
            public void updateFill(MetaObject metaObject) {
<<<<<<< HEAD
                // 处理LocalDateTime类型字段
                this.strictUpdateFill(metaObject, "updatedAt", LocalDateTime::now, LocalDateTime.class);
                
                // 处理Date类型字段
                this.strictUpdateFill(metaObject, "updatedAt", Date::new, Date.class);
=======
                this.strictUpdateFill(metaObject, "updatedAt", LocalDateTime::now, LocalDateTime.class);
>>>>>>> 312a8547971bd28c72072d07caef702821bd7891
            }
        };
    }
} 